const express = require("express");
const router = express.Router();
const controller = require("../controller/deviceCategory");

/**
 * @swagger
 * tags:
 *   - name: DeviceCategory
 *     description: 设备分类管理接口
 */

/**
 * @swagger
 * /category/device-categories:
 *   get:
 *     summary: 获取所有设备分类
 *     tags:
 *       - DeviceCategory
 *     responses:
 *       200:
 *         description: 设备分类列表
 */
router.get("/device-categories", controller.findAll);

/**
 * @swagger
 * /category/device-categories/{id}:
 *   get:
 *     summary: 获取单个设备分类详情
 *     tags:
 *       - DeviceCategory
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *         description: 设备分类ID
 *     responses:
 *       200:
 *         description: 设备分类详情
 *       404:
 *         description: 设备分类不存在
 */
router.get("/device-categories/:id", controller.find);

/**
 * @swagger
 * /category/device-categories:
 *   post:
 *     summary: 新建设备分类
 *     tags:
 *       - DeviceCategory
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required:
 *               - name
 *             properties:
 *               name:
 *                 type: string
 *               description:
 *                 type: string
 *     responses:
 *       201:
 *         description: 新建设备分类成功
 *       400:
 *         description: 参数错误
 */
router.post("/device-categories", controller.add);

/**
 * @swagger
 * /category/device-categories/{id}:
 *   put:
 *     summary: 更新设备分类
 *     tags:
 *       - DeviceCategory
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *         description: 设备分类ID
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required:
 *               - name
 *             properties:
 *               name:
 *                 type: string
 *               description:
 *                 type: string
 *     responses:
 *       200:
 *         description: 更新成功
 *       400:
 *         description: 参数错误或名称已存在
 *       404:
 *         description: 设备分类不存在
 */
router.put("/device-categories/:id", controller.update);

/**
 * @swagger
 * /category/device-categories/{id}:
 *   delete:
 *     summary: 删除设备分类
 *     tags:
 *       - DeviceCategory
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: integer
 *         description: 设备分类ID
 *     responses:
 *       204:
 *         description: 删除成功，无返回内容
 *       404:
 *         description: 设备分类不存在
 */
router.delete("/device-categories/:id", controller.remove);

module.exports = router;